{extend name="public:base"}
{block name="css"}
<link href="__PUBLIC__/css/login.min.css" rel="stylesheet">
{/block}
{block name="js"}
<script src="__PUBLIC__/js/plugins/layer/layer.min.js"></script>
<script>
    if (window.top !== window.self) {
        window.top.location = window.location;
    }

    //去除左右空格
    function trim(s){
        return s.replace(/(^\s*)|(\s*$)/g, "");
    }

    function CheckForm(){
        var fmfiled={0:['username','请输入用户名！'],1:['password','请输入密码！'],2:['code','请输入验证码！']};
        for(var i=0;i<3;i++){
            var val=document.getElementsByName(fmfiled[i][0])[0].value;
            if(trim(val) == ""){
                layer.msg(fmfiled[i][1]);
                return false;
            }
        }

        ajaxsubmit();

    }

    function ajaxsubmit(){
        var obj = showMyLoading();
        $.post('',$('form').serialize(),function(data){
            hideMyLoading(obj);
            if (data.status == 'y') {
                window.location.href = '{:url("Index/index")}';
            } else {
                $('input[name=code]').next().click();
                $('input[name=code]').val('');
                layer.msg(data.info);
            }
        }, 'json');
    }
</script>
{/block}
{block name="body"}
<body class="signin">
<div class="signinpanel">
    <div class="row">
  
        <div class="col-sm-5" style="width: 100%;">
            <form method="post" action="" onsubmit='CheckForm();return false;'>
                <h4 class="no-margins">登录：</h4>
                <input type="text" class="form-control uname" name="username" placeholder="用户名" style="color:#444;" />
                <input type="password" class="form-control pword m-b" name="password" placeholder="密码" style="color:#444;" />
                <div>
                    <input type="text" class="form-control" name="code" placeholder="用户名" style="color:#444;width:133px;float:left;margin-top:0;margin-bottom:15px;" />
                    <img src="{:captcha_src()}" onclick="$(this).attr('src', '{:captcha_src()}')" style="width:100px;height:34px;cursor:pointer;float:right;"/>
                </div>
                <input type="submit" class="btn btn-success btn-block" value="登陆"  />
            </form>
        </div>
    </div>
   
</div>

</body>
{/block}
